/*
 *  InterpolatedData.cpp
 *  MarketDataAnalyzer 2
 *
 *  Created by jiro on 10/10/02.
 *  Copyright 2010 jiro music. All rights reserved.
 *
 */

#include "InterpolatedData.h"
#include <iostream>

InterpolatedData::InterpolatedData( const std::vector< double >& validData, int sampleCount )
	: sampleCount( sampleCount ),
	  validData( validData ),
	  density( (double) validData.size() / sampleCount )
{
	srand( time( NULL ) );
}

double InterpolatedData::GetAt( int index ) const
{
//	std::cout << "base called get at\n";
	int reIndex = static_cast<int>( density * index );
	int randomIndex = rand() % ( validData.size() - 1 );
	double randomRate = validData[ randomIndex ] / validData[ randomIndex + 1 ];
	return randomRate * validData[ reIndex ];
}

InterpolatedData::InterpolationType InterpolatedData::GetInterpolationType() const
{
//	std::cout << "base called\n";
	return InterpolatedData::NearestNeighbourProbabilityRevision;
}

double InterpolatedData::GetDensity() const
{
	return validData.size() / sampleCount;
}

double InterpolatedData::GetSampleCount() const
{
	return sampleCount;
}

double InterpolatedData::GetValidDataCount() const
{
	return validData.size();
}

const std::vector< double > InterpolatedData::GetValidData() const
{
	return validData;
}
